package mhcs.client;


import java.util.TreeSet;

import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.StackPanel;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.HasVerticalAlignment;

public class MainMenu extends Composite{
    
    public static ManualLandingMap manualLandingMap;
    public static TreeSet<Module> manualList;
    //public static Iterator<Module> manualIter;
    
    
    public MainMenu() {
            
    	manualList = new TreeSet<Module>();

    	final TenDayWarning tenDayWarn = new TenDayWarning();

    	//10 Day Alert Warning on a timer and using a DialogBox as popup
    	Timer calibrate = new Timer() {
    		@Override
    		public void run() {
    			MHCS.soundOutput.playSound5();
    			tenDayWarn.show();
    			tenDayWarn.center();           
    		}
    	};
    	calibrate.scheduleRepeating(180000);
    	

    	FlexTable flexTableWrapper = new FlexTable();
        flexTableWrapper.setStyleName("gwt-Main-Menu-Wrapper");
        initWidget(flexTableWrapper);
        flexTableWrapper.setSize("100%", "900px");
        
        FlexTable flexTable_8 = new FlexTable();
        flexTable_8.setStyleName("gwt-Main-Menu-Header");
        flexTableWrapper.setWidget(0, 0, flexTable_8);
        flexTable_8.setSize("100%", "50px");
		
		Label lblNewLabel = new Label("Mars Habitat Configuration System");
		lblNewLabel.setStyleName("gwt-Main-Title");
		flexTable_8.setWidget(0, 0, lblNewLabel);
		flexTable_8.getCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER);
		flexTable_8.getCellFormatter().setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_TOP);
		flexTableWrapper.getCellFormatter().setHorizontalAlignment(1, 0, HasHorizontalAlignment.ALIGN_CENTER);
		
		FlexTable flexTable = new FlexTable();
		flexTable.setStyleName("gwt-Main-Menu-Header-Bottom");
		flexTableWrapper.setWidget(1, 0, flexTable);
		flexTable.setSize("100%", "50px");
		
		LogMenuButton lgmnbtnLogMenu = new LogMenuButton();
		flexTable.setWidget(0, 0, lgmnbtnLogMenu);
		lgmnbtnLogMenu.setWidth("");
		
		GPSButton btnGpsController = new GPSButton();
		flexTable.setWidget(0, 1, btnGpsController);
		
		MinConfigButton minConfigButton = new MinConfigButton();
		flexTable.setWidget(0, 2, minConfigButton);
		minConfigButton.setSize("90px", "30px");
		
		SaveLoadConfig saveLoadConfig = new SaveLoadConfig();
		flexTable.setWidget(0, 3, saveLoadConfig);
		
		WeatherWidget weatherWidget = new WeatherWidget();
		flexTable.setWidget(0, 4, weatherWidget);
		weatherWidget.setSize("200px", "50px");
		flexTable.getCellFormatter().setHorizontalAlignment(0, 12, HasHorizontalAlignment.ALIGN_CENTER);
		flexTable.getCellFormatter().setVerticalAlignment(0, 7, HasVerticalAlignment.ALIGN_TOP);
		flexTable.getCellFormatter().setVerticalAlignment(0, 10, HasVerticalAlignment.ALIGN_TOP);
		flexTable.getFlexCellFormatter().setColSpan(0, 8, 2);
		flexTable.getCellFormatter().setVerticalAlignment(0, 8, HasVerticalAlignment.ALIGN_TOP);
		flexTable.getCellFormatter().setHorizontalAlignment(0, 1, HasHorizontalAlignment.ALIGN_CENTER);
		flexTable.getCellFormatter().setHorizontalAlignment(0, 2, HasHorizontalAlignment.ALIGN_CENTER);
		flexTable.getCellFormatter().setHorizontalAlignment(0, 3, HasHorizontalAlignment.ALIGN_CENTER);
		flexTable.getCellFormatter().setHorizontalAlignment(0, 7, HasHorizontalAlignment.ALIGN_CENTER);
		flexTable.getCellFormatter().setVerticalAlignment(0, 4, HasVerticalAlignment.ALIGN_TOP);
		flexTable.getCellFormatter().setHorizontalAlignment(0, 4, HasHorizontalAlignment.ALIGN_CENTER);
		
		Logout logout_1 = new Logout();
		flexTable.setWidget(0, 5, logout_1);
		flexTable.getCellFormatter().setHorizontalAlignment(0, 5, HasHorizontalAlignment.ALIGN_RIGHT);
		flexTable.getCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER);
		flexTable.getCellFormatter().setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_MIDDLE);
		flexTable.getCellFormatter().setVerticalAlignment(0, 1, HasVerticalAlignment.ALIGN_MIDDLE);
		flexTable.getCellFormatter().setVerticalAlignment(0, 2, HasVerticalAlignment.ALIGN_MIDDLE);
		flexTable.getCellFormatter().setVerticalAlignment(0, 3, HasVerticalAlignment.ALIGN_MIDDLE);
		flexTable.getCellFormatter().setVerticalAlignment(0, 5, HasVerticalAlignment.ALIGN_MIDDLE);
		flexTableWrapper.getCellFormatter().setVerticalAlignment(2, 0, HasVerticalAlignment.ALIGN_TOP);
		
		StackPanel stackPanel = new StackPanel();
		stackPanel.setStyleName("gwt-StackPanel-MainMenu");
		flexTableWrapper.setWidget(2, 0, stackPanel);
		stackPanel.setSize("100%", "600px");
		
		LandingMap landingMap = new LandingMap();
		stackPanel.add(landingMap, "Landing Map", false);
		landingMap.setSize("1300px", "100%");
		ConfigMap configMap = new ConfigMap();
		configMap.setSize("1300px", "100%");
		stackPanel.add(configMap, "Configurations Map", false);
		
		ManualLandingMap manualLandingMap = new ManualLandingMap();
		stackPanel.add(manualLandingMap, "Manual Configuration Map", false);
		manualLandingMap.setSize("100%", "100%");
		flexTableWrapper.getCellFormatter().setVerticalAlignment(6, 0, HasVerticalAlignment.ALIGN_TOP);
		flexTableWrapper.getCellFormatter().setVerticalAlignment(3, 0, HasVerticalAlignment.ALIGN_TOP);
		
		
		
	}

}
